#pragma once

#include <QObject>
#include <QString>
#include <QHash>
#include <memory>
#include "kernel/interfaces/ILogger.h"

namespace application {
namespace auto_door {

/**
 * @brief 自动门状态枚举
 */
enum class DoorState {
    Closed,     // 关闭
    Opening,    // 正在打开
    Open,       // 打开
    Closing     // 正在关闭
};

/**
 * @brief 自动门类
 */
class AutoDoor : public QObject {
    Q_OBJECT

public:
    explicit AutoDoor(int doorId, const QString& point1, const QString& point2,
                      std::shared_ptr<kernel::ILogger> logger = nullptr, QObject* parent = nullptr);
    ~AutoDoor() = default;

    // 基本信息
    int getDoorId() const { return m_doorId; }
    QString getPoint1() const { return m_point1; }
    QString getPoint2() const { return m_point2; }
    DoorState getState() const { return m_state; }

    // 门控制
    void open();
    void close();
    bool isOpen() const { return m_state == DoorState::Open; }
    bool isClosed() const { return m_state == DoorState::Closed; }

signals:
    void stateChanged(DoorState state);
    void doorOpened();
    void doorClosed();

private:
    int m_doorId;
    QString m_point1;       // 触发点1
    QString m_point2;       // 触发点2
    DoorState m_state = DoorState::Closed;
    std::shared_ptr<kernel::ILogger> m_logger;
};

} // namespace auto_door
} // namespace application
